/*
 * @Description:
 * @User: Vijay <1937832819@qq.com>
 * @Date: 2020-10-20 22:34:11
 */
package routers

import (
	. "blogApi/controllers"
	"blogApi/controllers/admin"

	"github.com/astaxie/beego"
)

func init() {
	// 前端路由
	beego.Router("/", &MainController{})
	home := beego.NewNamespace("/home",
		beego.NSRouter("/article_list", &HomeController{}, "get:ArticleList"),
		beego.NSRouter("/article/:id([0-9]+)", &HomeController{}, "get:Article"),
		beego.NSRouter("/article_top", &HomeController{}, "get:ArticleTop"),
		beego.NSRouter("/home/category", &HomeController{}, "get:Category"),
	)
	beego.AddNamespace(home)

	// 后台需要验证的路由
	ns := beego.NewNamespace("/admin",
		beego.NSNamespace("/admin",
			beego.NSRouter("/login", &admin.AdminController{}, "post:Login"),
			beego.NSRouter("/logout", &admin.AdminController{}, "post:Logout"),
		),
		beego.NSNamespace("/tag",
			beego.NSRouter("/index", &admin.TagController{}, "get:Index"),
			beego.NSRouter("/store", &admin.TagController{}, "post:Store"),
			beego.NSRouter("/update", &admin.TagController{}, "put:Update"),
			beego.NSRouter("/destroy", &admin.TagController{}, "delete:Destroy"),
		),
		beego.NSNamespace("/article",
			beego.NSRouter("/index", &admin.ArticleController{}, "get:Index"),
			beego.NSRouter("/info", &admin.ArticleController{}, "get:Info"),
			beego.NSRouter("/store", &admin.ArticleController{}, "post:Store"),
			beego.NSRouter("/upload", &admin.ArticleController{}, "post:Upload"),
			beego.NSRouter("/update", &admin.ArticleController{}, "put:Update"),
			beego.NSRouter("/destroy", &admin.ArticleController{}, "delete:Destroy"),
		),
		beego.NSNamespace("/category",
			beego.NSRouter("/index", &admin.CategoryController{}, "get:Index"),
			beego.NSRouter("/store", &admin.CategoryController{}, "post:Store"),
			beego.NSRouter("/update", &admin.CategoryController{}, "put:Update"),
			beego.NSRouter("/destroy", &admin.CategoryController{}, "delete:Destroy"),
		),
		beego.NSNamespace("/comment",
			beego.NSRouter("/index", &admin.CommentController{}, "get:Index"),
			beego.NSRouter("/update", &admin.CommentController{}, "put:Update"),
			beego.NSRouter("/replace", &admin.CommentController{}, "put:Replace"),
			beego.NSRouter("/destroy", &admin.CommentController{}, "delete:Destroy"),
		),
		beego.NSNamespace("/system",
			beego.NSRouter("/index", &admin.SystemController{}, "get:Index"),
			beego.NSRouter("/save", &admin.SystemController{}, "post:Save"),
		),
		beego.NSNamespace("/chat",
			beego.NSRouter("/index", &admin.ChatController{}, "get:Index"),
			beego.NSRouter("/store", &admin.ChatController{}, "post:Store"),
			beego.NSRouter("/update", &admin.ChatController{}, "put:Update"),
			beego.NSRouter("/destroy", &admin.ChatController{}, "delete:Destroy"),
		),
		beego.NSNamespace("/friend_link",
			beego.NSRouter("/index", &admin.FriendLinkController{}, "get:Index"),
			beego.NSRouter("/store", &admin.FriendLinkController{}, "post:Store"),
			beego.NSRouter("/update", &admin.FriendLinkController{}, "put:Update"),
			beego.NSRouter("/destroy", &admin.FriendLinkController{}, "delete:Destroy"),
		),
		beego.NSNamespace("/nav",
			beego.NSRouter("/index", &admin.NavController{}, "get:Index"),
			beego.NSRouter("/getTargetList", &admin.NavController{}, "get:GetTargetList"),
			beego.NSRouter("/store", &admin.NavController{}, "post:Store"),
			beego.NSRouter("/update", &admin.NavController{}, "put:Update"),
			beego.NSRouter("/destroy", &admin.NavController{}, "delete:Destroy"),
		),
		beego.NSNamespace("/role",
			beego.NSRouter("/index", &admin.RoleController{}, "get:Index"),
			beego.NSRouter("/getGuardNameList", &admin.RoleController{}, "get:GetGuardNameList"),
			beego.NSRouter("/getPermissionIdsByRole", &admin.RoleController{}, "get:GetPermissionIdsByRole"),
			beego.NSRouter("/store", &admin.RoleController{}, "post:Store"),
			beego.NSRouter("/update", &admin.RoleController{}, "put:Update"),
			beego.NSRouter("/destroy", &admin.RoleController{}, "delete:Destroy"),
		),
		beego.NSNamespace("/permission",
			beego.NSRouter("/index", &admin.PermissionController{}, "get:Index"),
			beego.NSRouter("/permissionTree", &admin.PermissionController{}, "get:PermissionTree"),
			beego.NSRouter("/store", &admin.PermissionController{}, "post:Store"),
			beego.NSRouter("/update", &admin.PermissionController{}, "put:Update"),
			beego.NSRouter("/destroy", &admin.PermissionController{}, "delete:Destroy"),
		),
	)
	beego.AddNamespace(ns)
}
